import Vue from 'vue'
import VueRouter from 'vue-router'



Vue.use(VueRouter)
//引入elementui
import ELementUI,{Message} from 'element-ui'
Vue.use(ELementUI)
import Login from '@/components/manager/Login.vue';
import Home from "../components/Home.vue";
import WelCome from "../components/WelCome.vue";
import CollectAll from '@/components/health/CollectAll.vue';
import Height from '@/components/health/Height.vue';
import Weight from '@/components/health/Weight.vue';
import Glu from '@/components/health/Glu.vue';
import Hr from '@/components/health/Hr.vue';
import Temp from '@/components/health/Temp.vue';
import Pulse from '@/components/health/Pulse.vue';
import Bp from '@/components/health/Bp.vue';
import Consulter from "@/components/customer/Consulter.vue";
import Medicine from "@/components/medicine/Medicine.vue";
import Cost from "../components/cost/Cost.vue";
import OtherCost from "../components/cost/OtherCost.vue";
import Older from "@/components/customer/Older.vue";
import Card from "@/components/card/Card.vue";
import Record from "@/components/card/Record.vue";
import RoomType from "@/components/bed/RoomType.vue";
import BedSite from "@/components/bed/BedSite.vue";

import OutApplication from "@/components/customer/OutApplication.vue";
import DeliveryBill from "@/components/medicine/DeliveryBill.vue";
import Delivery from "@/components/medicine/Delivery.vue";
import Contract from "@/components/customer/Contract.vue";
import Life from "@/components/customer/Life.vue";
import Warehouse from "@/components/medicine/Warehouse.vue";
import Overdue from "@/components/medicine/Overdue.vue";

import Label from "@/components/customer/Label.vue";
import ExitRegister from "@/components/customer/ExitRegister.vue";
import Electricity from "@/components/customer/Electricity.vue";

import OccupancyFee from "../components/cost/OccupancyFee.vue";
import Careproject from "@/components/careService/Careproject.vue";
import CareLevel from "@/components/careService/CareLevel.vue";
import DischargeSettlement from "@/components/cost/DischargeSettlement.vue";
import Food from "@/components/Food/Food.vue";
import Recipe from "@/components/Food/Recipe.vue";

import BedDynamic from "@/components/customer/BedDynamic.vue";
import ChangeCare from "@/components/customer/ChangeCare.vue";

import CardData from "@/components/datacollect/CardData.vue";
import OlderData from "@/components/datacollect/OlderData.vue";
import OccupancyFeeData from "@/components/datacollect/OccupancyFeeData.vue";
import aaa from "@/components/careService/aaa.vue";
import ChangeBed from "@/components/customer/ChangeBed.vue";

const routes = [
  {
    path:'/',
    name:'Login',
    component:Login
  },
  {
    path:'/login',
    name:'Login',
    component:Login
  },
  {
    path:"/Home",
    name:"Home",
    component:Home,
    children:[
      {
        path:"/",
        name:"WelCome",
        component:WelCome
      },
      {
        path:"/WelCome",
        name:"WelCome",
        component:WelCome
      },
      {
        path:"/Older",
        name:"Older",
        component:Older
      },
      {
        path:"/BedDynamic",
        name:"BedDynamic",
        component:BedDynamic
      },
      {
        path:"/OutApplication",
        name:"OutApplication",
        component:OutApplication
      },
      {
        path:"/Consulter",
        name:"Consulter",
        component:Consulter
      },
      {
        path:"/Medicine",
        name:"Medicine",
        component:Medicine
      },
      {
        path:"/Delivery",
        name:"Delivery",
        component:Delivery
      },
      {
        path:"/DeliveryBill",
        name:"DeliveryBill",
        component:DeliveryBill
      },
      {
        path:"/Warehouse",
        name:"Warehouse",
        component:Warehouse
      },
      {
        path:"/Overdue",
        name:"Overdue",
        component:Overdue
      },
      {
        path:"/ChangeBed",
        name:"ChangeBed",
        component:ChangeBed
      },
      {
        path:"/Careproject",
        name:"Careproject",
        component:Careproject
      },
      {
        path:"/CareLevel",
        name:"CareLevel",
        component:CareLevel
      },
      {
        path:"/aaa",
        name:"aaa",
        component:aaa
      },
      {
        path:"/Life",
        name:"Life",
        component:Life
      },
      {
        path:"/Contract",
        name:"Contract",
        component:Contract
      },
      {
        path:"/Older",
        name:"Older",
        component:Older
      },
      {
        path:"/CollectAll",
        name:"CollectAll",
        component:CollectAll
      },
      {
        path:"/Height",
        name:"Height",
        component:Height
      },
      {
        path:"/Weight",
        name:"Weight",
        component:Weight
      },
      {
        path:"/Glu",
        name:"Glu",
        component:Glu
      },
      {
        path:"/Hr",
        name:"Hr",
        component:Hr
      },
      {
        path:"/Temp",
        name:"Temp",
        component:Temp
      },
      {
        path:"/Pulse",
        name:"Pulse",
        component:Pulse
      },
      {
        path:"/Bp",
        name:"Bp",
        component:Bp
      },
      {
        path:"/Card",
        name:"Card",
        component:Card
      },
      {
        path:"/Electricity",
        name:"Electricity",
        component:Electricity
      },
      {
        path:"/Label",
        name:"Label",
        component:Label
      },
      {
        path:"/ExitRegister",
        name:"ExitRegister",
        component:ExitRegister
      },
      {
        path:"/Record",
        name:"Record",
        component:Record
      },
      {
        path:"/Cost",
        name:"Cost",
        component:Cost
      },
      {
        path:"/OtherCost",
        name:"OtherCost",
        component:OtherCost
      },

      {
        path:"/RoomType",
        name:"RoomType",
        component:RoomType
      },
      {
        path:"/BedSite",
        name:"BedSite",
        component:BedSite
      },

      {
        path:"/DischargeSettlement",
        name:"DischargeSettlement",
        component:DischargeSettlement
      },
      {
        path:"/OccupancyFee",
        name:"OccupancyFee",
        component:OccupancyFee
      },
      {
        path:"/Food",
        name:"Food",
        component:Food,
      },
      {
        path:"/Recipe",
        name:"Recipe",
        component:Recipe,
      },
      {
        path:"/ChangeCare",
        name:"ChangeCare",
        component:ChangeCare,
      },
      {
        path:"/CardData",
        name:"CardData",
        component:CardData,
      },
      {
        path:"/OlderData",
        name:"OlderData",
        component:OlderData,
      },
      {
        path:"/OccupancyFeeData",
        name:"OccupancyFeeData",
        component:OccupancyFeeData,
      },
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
// 路由守卫
router.beforeEach((to,from,next)=>{
  let path = to.path ;
  if (path == '/' || path == '/Login'){
    next();
  }else {
    let token = sessionStorage.getItem('token');
    if (token) {
      next();
    } else {
      Message({
        type:'error',
        message:'请先登录',
        duration:1000
      })
      next('/');
    }
  }
})

export default router
